    #include <boost/regex.hpp> 
    #include <locale> 
    #include <iostream> 
     
    int main() 
    { 
      std::string s = " Boris Schaling "; 
      boost::regex expr("\\s"); 
      std::string fmt("_"); 
      std::cout << boost::regex_replace(s, expr, fmt) << std::endl; 
    } 